//
//  HXTFLConsumViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/27.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "HXTFLConsumViewModel.h"
#import "HXTFLConsumModel.h"

static NSString *const fuliConsum_url = @"api/Hxt/HxtInfofulimx?";

@implementation HXTFLConsumViewModel

-(void)getHXTFLConsumWithPage:(NSString *)page success:(void (^)())completion{
    User *user = [User currentUser];
    NSDateFormatter *f = [NSDateFormatter new];
    f.dateFormat = @"yyyy-MM-dd";
    NSString *endDate = [f stringFromDate:[NSDate date]];
    NSString *beginDate = @"2012-01-01";
    NSString *pageSize = @"10";
    
    NSString *url = [NSString stringWithFormat:@"%@%@HxtCardNo=%@&startDate=%@&endDate=%@&pageNumber=%@&pageSize=%@",HOSPITAL_URL,fuliConsum_url,user.MedicalCard,beginDate,endDate,page,pageSize];
    [NetWorker getHXTDatasWithURLStr:url success:^(id result) {
        NSDictionary *resultDic = result[@"result"];
        NSArray *dataList = [JsonHelper arrayWithJsonString:resultDic[@"dataList"]];
        if (dataList.count > 0) {
            NSMutableArray *modelArr = [NSMutableArray array];
            for (NSDictionary *dic in dataList) {
                HXTFLConsumModel *model = [HXTFLConsumModel yy_modelWithDictionary:dic];
                [modelArr addObject:model];
            }
            _datasArray = modelArr;
            completion(modelArr);
        }
    } failure:^(id result) {
        [SVProgressHUD showErrorWithStatus:@"暂无更多数据"];
    }];

}

@end
